﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using uTools;

public class LevelHeartShape : MonoBehaviour
{
    public List<TextButton> tbList = new List<TextButton>();
    public uTweenAlpha tweenAlpha;
    public GameLevelItem gameLevelItem;
    // Start is called before the first frame update
    void Start()
    {
        
        int length = tbList.Count;
        for (int i = 0; i < length; i++)
        {
            int tempIndex = i;
            tbList[i].Init("", () =>
            {
                tbList[tempIndex].button.image.color = Color.red;
                JudgeResult();
            });
        }
    }

    private void JudgeResult()
    {
        int length = tbList.Count;
        bool result = true;
        for (int i = 0; i < length; i++)
        {
            if (!tbList[i].button.image.color.Equals(Color.red))
            {
                result = false;
                break;
            }
        }
        if (result)
        {
            tweenAlpha.Play(PlayDirection.Forward);
            gameLevelItem.TriggerResult(true);
        }
    }




}
